'use strict';

module.exports = app => {
    const { Sequelize, model } = app

    const Model = model.define('minaArea', {
        id:{
            type: Sequelize.STRING.BINARY,
            defaultValue: Sequelize.UUIDV1,
            primaryKey: true
        },
        name: {
            type: Sequelize.STRING(20),
            allowNull: false,
            comment: '地区名'
        },
        flag: {
            type: Sequelize.INTEGER(2),
            allowNull: false,
            comment: '开放状态'
        },
    }, {
        freezeTableName: true,
        tableName: 'mina_area',
    })

    Model.associate = function() {
        model.MinaArea.belongsTo(model.MinaCity)
        model.MinaCity.hasMany(model.MinaArea)
    }

    return Model
}